/**
 * 
 */
package com.siriusxm.www.mavenweb;

import com.opensymphony.xwork2.ActionSupport;
import com.siriusxm.www.mavencore.domain.User;
import com.siriusxm.www.mavencore.service.ILoginService;

/**
 * @author sbaral
 * 
 */
public class LoginAction extends ActionSupport {

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	protected String username;
	protected String password;
	
	protected ILoginService loginService;

	/**
	 * @return the username
	 */
	public String getUsername() {
		return username;
	}

	/**
	 * @param username
	 *            the username to set
	 */
	public void setUsername(String username) {
		this.username = username;
	}

	/**
	 * @return the password
	 */
	public String getPassword() {
		return password;
	}

	/**
	 * @param password
	 *            the password to set
	 */
	public void setPassword(String password) {
		this.password = password;
	}

	public String execute() {
		if (loginService.login(username, password) != null) {
			return "success";
		} else {
			return "error";
		}
	}

	/**
	 * @return the loginService
	 */
	public ILoginService getLoginService() {
		return loginService;
	}

	/**
	 * @param loginService the loginService to set
	 */
	public void setLoginService(ILoginService loginService) {
		this.loginService = loginService;
	}
	
	public User createUser() {
		User user = new User();
		user.setUsername(username);
		user.setPassword(password);
		return user;
	}
}
